home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Library / Manuels & Misc / Assembly / AOA.ZIP / CH11 / EX11_1.ASM < prev    next >
Encoding:
Assembly Source File  |  1996-02-13  |  4.5 KB  |  314 lines

  1.     ifndef    ??version
  2. ?debug    macro
  3.     endm
  4. publicdll macro    name
  5.     public    name
  6.     endm
  7. $comm    macro    name,dist,size,count
  8.     comm    dist name:BYTE:count*size
  9.     endm
  10.     else
  11. $comm    macro    name,dist,size,count
  12.     comm    dist name[size]:BYTE:count
  13.     endm
  14.     endif
  15.     ?debug    V 300h
  16.     ?debug    S "ex11_1.cpp"
  17.     ?debug    C E95B414D200A657831315F312E637070
  18. _TEXT    segment byte public 'CODE'
  19. _TEXT    ends
  20. DGROUP    group    _DATA,_BSS
  21.     assume    cs:_TEXT,ds:DGROUP
  22. _DATA    segment word public 'DATA'
  23. d@    label    byte
  24. d@w    label    word
  25. _DATA    ends
  26. _BSS    segment word public 'BSS'
  27. b@    label    byte
  28. b@w    label    word
  29. _BSS    ends
  30. _TEXT    segment byte public 'CODE'
  31.    ;    
  32.    ;    int main()
  33.    ;    
  34.     assume    cs:_TEXT
  35. _main    proc    near
  36.     push    bp
  37.     mov    bp,sp
  38.     sub    sp,4012
  39.     push    si
  40.     push    di
  41.    ;    
  42.    ;    {
  43.    ;        unsigned     SaveScr[25][80];
  44.    ;    
  45.    ;        int         dx,
  46.    ;                    x,
  47.    ;                    dy,
  48.    ;                    y;
  49.    ;    
  50.    ;        long        i;
  51.    ;    
  52.    ;        unsigned    savex,
  53.    ;                    savey;
  54.    ;    
  55.    ;    
  56.    ;    
  57.    ;        GetXY(savex, savey);
  58.    ;    
  59.     push    ss
  60.     lea    ax,word ptr [bp-12]
  61.     push    ax
  62.     push    ss
  63.     lea    ax,word ptr [bp-10]
  64.     push    ax
  65.     call    near ptr _GetXY
  66.     add    sp,8
  67.    ;    
  68.    ;        Capture(SaveScr);
  69.    ;    
  70.     push    ss
  71.     lea    ax,word ptr [bp-4012]
  72.     push    ax
  73.     call    near ptr _Capture
  74.     pop    cx
  75.     pop    cx
  76.    ;    
  77.    ;        ClrScrn();
  78.    ;    
  79.     call    near ptr _ClrScrn
  80.    ;    
  81.    ;    
  82.    ;        GotoXY(24,0);
  83.    ;    
  84.     xor    ax,ax
  85.     push    ax
  86.     mov    ax,24
  87.     push    ax
  88.     call    near ptr _GotoXY
  89.     pop    cx
  90.     pop    cx
  91.    ;    
  92.    ;        PutStr("Press any key to quit");
  93.    ;    
  94.     push    ds
  95.     mov    ax,offset DGROUP:s@
  96.     push    ax
  97.     call    near ptr _PutStr
  98.     pop    cx
  99.     pop    cx
  100.    ;    
  101.    ;    
  102.    ;        dx = 1;
  103.    ;    
  104.     mov    word ptr [bp-2],1
  105.    ;    
  106.    ;        dy = 1;
  107.    ;    
  108.     mov    word ptr [bp-4],1
  109.    ;    
  110.    ;        x = 1;
  111.    ;    
  112.     mov    si,1
  113.    ;    
  114.    ;        y = 1;
  115.    ;    
  116.     mov    di,1
  117.     jmp    @1@422
  118. @1@58:
  119.    ;    
  120.    ;        while (!tstKbd())
  121.    ;        {
  122.    ;    
  123.    ;        GotoXY(y, x);
  124.    ;    
  125.     push    si
  126.     push    di
  127.     call    near ptr _GotoXY
  128.     pop    cx
  129.     pop    cx
  130.    ;    
  131.    ;            PutChar('#');
  132.    ;    
  133.     mov    al,35
  134.     push    ax
  135.     call    near ptr _PutChar
  136.     pop    cx
  137.    ;    
  138.    ;    
  139.    ;            for (i=0; i<500000; ++i);
  140.    ;    
  141.     mov    word ptr [bp-6],0
  142.     mov    word ptr [bp-8],0
  143.     jmp    short @1@114
  144. @1@86:
  145.     add    word ptr [bp-8],1
  146.     adc    word ptr [bp-6],0
  147. @1@114:
  148.     cmp    word ptr [bp-6],7
  149.     jl    short @1@86
  150.     jne    short @1@198
  151.     cmp    word ptr [bp-8],-24288
  152.     jb    short @1@86
  153. @1@198:
  154.    ;    
  155.    ;    
  156.    ;            GotoXY(y, x);
  157.    ;    
  158.     push    si
  159.     push    di
  160.     call    near ptr _GotoXY
  161.     pop    cx
  162.     pop    cx
  163.    ;    
  164.    ;            PutChar(' ');
  165.    ;    
  166.     mov    al,32
  167.     push    ax
  168.     call    near ptr _PutChar
  169.     pop    cx
  170.    ;    
  171.    ;    
  172.    ;    
  173.    ;    
  174.    ;        x += dx;
  175.    ;    
  176.     add    si,word ptr [bp-2]
  177.    ;    
  178.    ;            y += dy;
  179.    ;    
  180.     add    di,word ptr [bp-4]
  181.    ;    
  182.    ;            if (x >= 79)
  183.    ;    
  184.     cmp    si,79
  185.     jl    short @1@254
  186.    ;    
  187.    ;        {
  188.    ;                x = 78;
  189.    ;    
  190.     mov    si,78
  191.    ;    
  192.    ;                dx = -1;
  193.    ;    
  194.     mov    word ptr [bp-2],-1
  195.    ;    
  196.    ;        }
  197.    ;    
  198.     jmp    short @1@310
  199. @1@254:
  200.    ;    
  201.    ;            else if (x <= 0)
  202.    ;    
  203.     or    si,si
  204.     jg    short @1@310
  205.    ;    
  206.    ;        {
  207.    ;                x = 1;
  208.    ;    
  209.     mov    si,1
  210.    ;    
  211.    ;                dx = 1;
  212.    ;    
  213.     mov    word ptr [bp-2],1
  214. @1@310:
  215.    ;    
  216.    ;        }
  217.    ;    
  218.    ;            if (y >= 24)
  219.    ;    
  220.     cmp    di,24
  221.     jl    short @1@366
  222.    ;    
  223.    ;        {
  224.    ;                y = 23;
  225.    ;    
  226.     mov    di,23
  227.    ;    
  228.    ;                dy = -1;
  229.    ;    
  230.     mov    word ptr [bp-4],-1
  231.    ;    
  232.    ;        }
  233.    ;    
  234.     jmp    short @1@422
  235. @1@366:
  236.    ;    
  237.    ;            else if (y <= 0)
  238.    ;    
  239.     or    di,di
  240.     jg    short @1@422
  241.    ;    
  242.    ;        {
  243.    ;                y = 1;
  244.    ;    
  245.     mov    di,1
  246.    ;    
  247.    ;                dy = 1;
  248.    ;    
  249.     mov    word ptr [bp-4],1
  250. @1@422:
  251.     call    near ptr _tstKbd
  252.     or    ax,ax
  253.     jne    @@0
  254.     jmp    @1@58
  255. @@0:
  256.    ;    
  257.    ;        }
  258.    ;    
  259.    ;    
  260.    ;        }
  261.    ;    
  262.    ;        PutScr(SaveScr);
  263.    ;    
  264.     push    ss
  265.     lea    ax,word ptr [bp-4012]
  266.     push    ax
  267.     call    near ptr _PutScr
  268.     pop    cx
  269.     pop    cx
  270.    ;    
  271.    ;        GotoXY(savey, savex);
  272.    ;    
  273.     push    word ptr [bp-10]
  274.     push    word ptr [bp-12]
  275.     call    near ptr _GotoXY
  276.     pop    cx
  277.     pop    cx
  278.    ;    
  279.    ;        return 0;
  280.    ;    
  281.     xor    ax,ax
  282.     jmp    short @1@478
  283. @1@478:
  284.    ;    
  285.    ;    }
  286.    ;    
  287.     pop    di
  288.     pop    si
  289.     mov    sp,bp
  290.     pop    bp
  291.     ret    
  292. _main    endp
  293.     ?debug    C E9
  294.     ?debug    C FA00000000
  295. _TEXT    ends
  296. _DATA    segment word public 'DATA'
  297. s@    label    byte
  298.     db    'Press any key to quit'
  299.     db    0
  300. _DATA    ends
  301. _TEXT    segment byte public 'CODE'
  302. _TEXT    ends
  303.     public    _main
  304.     extrn    _PutStr:near
  305.     extrn    _PutChar:near
  306.     extrn    _PutScr:near
  307.     extrn    _Capture:near
  308.     extrn    _tstKbd:near
  309.     extrn    _ClrScrn:near
  310.     extrn    _GetXY:near
  311.     extrn    _GotoXY:near
  312. _s@    equ    s@
  313.     end
  314.